/**
 * 根据组件名获取父级
 * @param vm
 * @param name
 * @returns {Vue | null|null|Vue}
 */
export function getVmParentByName(vm, name) {
    let parent = vm.$parent
    if (parent && parent.$options) {
        if (parent.$options.name === name) {
            return parent
        } else {
            let res = getVmParentByName(parent, name)
            if (res) {
                return res
            }
        }
    }
    return null
}


//获取周一至周五,到周日的话i=> 5变为7
export const getDataArea = (currentTime) => {
    var currentDate = new Date(currentTime)

    var timesStamp = currentDate.getTime();

    var currenDay = currentDate.getDay();

	var dateList = [];
    for (var i = 0; i < 5; i++) {
        const dates = new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7))
        // console.log(dates,);
        const Y = dates.getFullYear() // 年
         const M = prefixZero(dates.getMonth() + 1) //月
        const D = prefixZero(dates.getDate()); //日
        // const H = prefixZero(dates.getHours()); //时
        // const m = prefixZero(dates.getMinutes()); //分
        // const s = prefixZero(dates.getSeconds()); //秒
        const Time = `${Y}-${M}-${D}`;
        // console.log(Time,'Time');
        dateList.push(Time);
    
    }
	return dateList
}

function prefixZero(num = 0, n = 2) {
  // 数字位数不够，数字前面补零
  return (Array(n).join('0') + num).slice(-n);
}